package com.junchao.peng.controller;

import com.junchao.peng.pojo.Session;
import com.junchao.peng.service.SessionService;
import com.junchao.peng.utils.JsonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author dell
 */
@RestController
@RequestMapping("/session")
public class SessionController {
    @Resource
    SessionService sessionService;

    @ApiOperation("获取会议表内所有数据")
    @GetMapping("/listSession")
    public JsonResult listSession(String token){
        return sessionService.listSession(token);
    }

    @ApiOperation("获取一个会议信息")
    @GetMapping("/selectSessionBySessionName")
    public JsonResult selectSessionBySessionName(String sessionName, String token){
        return sessionService.selectSessionBySessionName(sessionName,token);
    }

    @ApiOperation("获取会议表内指定用户创建的所有会议")
    @GetMapping("/listSessionByUserName")
    public JsonResult listSessionByUserName(String userName, String token){
        return sessionService.listSessionByUserName(userName, token);
    }

    @ApiOperation("删除会议名相同的会议")
    @DeleteMapping("/deleteSession")
    public JsonResult deleteSession(String session,String token){
        return sessionService.deleteSession(session, token);
    }

    @ApiOperation("新建一个会议")
    @PostMapping("/insertSession")
    public JsonResult insertSession(Session session, String token){
        return sessionService.insertSession(session, token);
    }

    @ApiOperation("修改会议信息")
    @PutMapping("/updateSession")
    public JsonResult updateSession(Session session, String token){
        return sessionService.updateSession(session,token);
    }
}
